unit gridfs;

interface

uses
  mongo,
  bson;

const
  DEFAULT_CHUNK_SIZE = 256 * 1024;

type
  TGridFSOffset = UInt64;

  // A GridFS represents a single collection of GridFS files in the database.
  TGridFS = record
    client: PMongo;    // The client to db-connection.
    dbname: string;    // The root database name
    prefix: string;    // The prefix of the GridFS's collections, default is NULL
    files_ns: string;  // The namespace where the file's metadata is stored
    chunks_ns: string; // The namespace where the files's data is stored in chunks
  end;
  PGridFS = ^TGridFS;

  // A GridFile is a single GridFS file.
  TGridFile = record
    gfs: PGridFS;          // The GridFS where the GridFile is located
    meta: PBson;           // The GridFile's bson object where all its metadata is located
    pos: TGridFSOffset;    // The position is the offset in the file
    id: TBsonOid;          // The files_id of the gridfile
    remote_name: string;   // The name of the gridfile as a string
    content_type: string;  // The gridfile's content type
    length: TGridFSOffset; // The length of this gridfile
    chunk_num: Integer;    // The number of the current chunk being written to
    pending_data: PByte;   // A buffer storing data still to be written to chunks
    pending_len: Integer;  // Length of pending_data buffer
  end;
  PGridFile = ^TGridFile;

implementation

end.
